package com.example.hello.mapper;

import com.example.hello.pojo.UserBorrowCertificate;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserBorrowCertificateMapper {

    /**
     * 根据证件ID 查询借阅证信息。
     * <p>假设证件ID 与用户ID 一一对应，故在 borrowService 直接传 userId。</p>
     */
    @Select("SELECT " +
            "id, " +
            "max_borrow_book_num   AS maxBorrowBookNum, " +
            "max_borrow_day        AS maxBorrowDay, " +
            "overdue_pay_per_day   AS overduePayPerDay, " +
            "authority_name        AS authorityName, " +
            "created_at            AS createdAt, " +
            "updated_at            AS updatedAt " +
            "FROM user_borrow_certificate " +
            "WHERE id = #{certificateId}")
    UserBorrowCertificate getById(Integer certificateId);
}